package dao.imp;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import vo.Navigate;
import dao.NavigateDao;

public class NavigateDaoImp extends SimpleJdbcDaoSupport implements NavigateDao {
	
	private ParameterizedRowMapper<Navigate> rm=new ParameterizedRowMapper<Navigate>(){
		public Navigate mapRow(ResultSet rs,int index)throws SQLException{
			Navigate navigate=new Navigate();
			navigate.setId(rs.getInt("id"));
			navigate.setName(rs.getString("name"));
			navigate.setParentId(rs.getInt("parentId"));
			return navigate;
		} 
	};
	//====================================================
	public List<Navigate> getAllNavigates() {
		String sql="select * from navigates";
		List<Navigate> list =getSimpleJdbcTemplate().query(sql, rm);
		return list.isEmpty()? null:list;
	}

}
